package 动态规划9月;
// https://leetcode-cn.com/problems/print-in-order/
public class 按序打印0920多线程 {
    class Foo {

        public Foo() {

        }
        volatile int count=1;
        public void first(Runnable printFirst) throws InterruptedException {
            printFirst.run();
            count++;
        }

        public void second(Runnable printSecond) throws InterruptedException {
            while (count!=2);
            printSecond.run();
            count++;
        }

        public void third(Runnable printThird) throws InterruptedException {
            while (count!=3);
            printThird.run();
        }
    }

}
